Does the probeAttr_ function use a lot of CPU resources (relatively) within a program compared to using a variable? I have a module that contains thousands of objects. In my comparison script, it is using probeAttr_ to check for the existence of certain attributes on every object or to see if they are empty strings (i.e. probeAttr_(oOldObj, attr) != ""). I'm wondering if this is really using a lot of CPU resources each time it uses this function. If so, I may need to change it so that it only uses probeAttr to check the existence of an attribute and setting a Boolean variable to true or false for attributes instead.
Chris Cote chrscote - Thu Jan 26 15:42:25 EST 2017 |
Re: CPU Usage for probeAttr_ probeAttr_ is smart, but slow. I found in the past that you get a significant speedup checking for the existence of attributes only once (not for every value read), but that should be clear. So if you worry about performance, do the checks before reading. Regards, Mathias Edit: There are other ways to check for the existence of an attribute by the way. The easiest should be "exists", I used to do AttrDef find (to also check if its an object attribute). |
Re: CPU Usage for probeAttr_ OK, "exists" works fine if I'm checking for an attribute in one object, but what if you want to check for the same attribute in 2 objects (one each coming from 2 modules)? The "exists" function only works with a module that's been selected. And find can only be used on Module variables. I want to make sure that an attribute appears in both objects I'm testing and then check the values of the attribute to see if they are different.
Chris |